﻿
@{
    ViewData["Title"] = "EmailConfig";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style>
    .layui-inline {
        margin-bottom: 25px;
        margin-right: 0;
    }

    .layui-form-label {
        width: 115px;
    }

    .layui-input-block {
        margin-left: 150px;
    }

    .form-group-bottom {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: #fff;
        padding: 10px 20px;
        box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, .05);
    }
</style>
<!-- 正文开始 -->
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" lay-filter="emailConfig">
                        <div class="layui-fluid" style="padding-bottom: 75px;">
                            <div class="layui-row">
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">Smtp发送邮件服务器:</label>
                                    <div class="layui-input-block">
                                        <input name="smtpHost" type="text" class="layui-input" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">Smtp邮件服务器端口:</label>
                                    <div class="layui-input-block">
                                        <input name="smtpPort" type="text" class="layui-input" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">是否开启SSL:</label>
                                    <div class="layui-input-block">
                                        <select name="isSsl">
                                            <option value="0">不开启</option>
                                            <option value="1">开启</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">邮箱账户:</label>
                                    <div class="layui-input-block">
                                        <input name="emailAccount" type="text" class="layui-input" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">邮箱密码:</label>
                                    <div class="layui-input-block">
                                        <input name="emailPassword" type="password" class="layui-input" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">提醒收件箱:</label>
                                    <div class="layui-input-block">
                                        <input name="tipEmail" type="text" class="layui-input" />
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group-bottom text-right">
                            <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
                            <button class="layui-btn" lay-filter="formSubmitEmail" lay-submit>&emsp;提交&emsp;</button>
                        </div>

                    </form>
                </div>
            </div>
        </div>


    </div>
</div>
<script>
    layui.use(['element', 'layer', 'form', 'table', 'util', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        form.render('select');
        layer.load(2);
        $.ajax({
            url: '/api/Quartz/QuaryEmailConfig',
            type: 'get',
            contentType: "application/json;charset=utf-8",
            async: true,
            dataType: 'json',
            complete: function (obj) {
                layer.closeAll('loading');
            },
            success: function (res) {
                if (res.success) {
                    form.val('emailConfig', res.data);
                    form.render('select');
                }
            }
        });

        //提交
        form.on('submit(formSubmitEmail)', function (data) {
            layer.load(2);
            $.ajax({
                url: '/api/Quartz/SubmitEmail',
                type: 'post',
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(data.field),
                async: true,
                dataType: 'json',
                complete: function (obj) {
                    layer.closeAll('loading');
                },
                success: function (res) {
                    if (res.success) {
                        location.reload();
                    }
                }
            });
            return false;
        });
    });
</script>

